var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var util = require('util');

var Event = new Schema({
	what : {
		type : String,
		unique : true
	},
	where : {
		type : String
	},
	fbPlace : {
		type : Number,
		index : true
	},
	when : {
		type : Date
	}
});

Event.statics.startup = function() {
	var boot = new model.Event();
	boot.what = 'bootstrap00000';
	boot.where = 'nowhere';
	boot.when = Date.now();
	boot.save(function(e) {
		model.Event.remove({
			what : 'bootstrap00000'
		}, function(e) {
			if (e) {
				util.log(e.type + ": " + e.message);
				util.puts(e.stack);
			}
		});
	});
};

model.Event = connection.model('Event', Event);